//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.jim.core.packets;

import com.alibaba.fastjson.JSONObject;
import java.io.Serializable;
import org.jim.core.utils.JsonKit;

public class Message implements Serializable {
	private static final long serialVersionUID = -6375331164604259933L;
	protected Long createTime;
	protected String id;
	protected String appId;
	protected String scope = "chat";
	protected Integer cmd;
	protected JSONObject extras;

	public Message() {
	}

	public String getAppId() {
		return this.appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getScope() {
		return this.scope;
	}

	public void setScope(String scope) {
		this.scope = scope;
	}

	public Long getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Integer getCmd() {
		return this.cmd;
	}

	public void setCmd(Integer cmd) {
		this.cmd = cmd;
	}

	public JSONObject getExtras() {
		return this.extras;
	}

	public void setExtras(JSONObject extras) {
		this.extras = extras;
	}

	public String toJsonString() {
		return JsonKit.toJSONString(this);
	}

	public byte[] toByte() {
		return JsonKit.toJsonBytes(this);
	}

	public abstract static class Builder<T extends Message, B extends Builder<T, B>> {
		protected Long createTime;
		protected String id;
		protected String appId = "10000000000000000001";
		protected String scope = "chat";
		protected Integer cmd;
		protected JSONObject extras;
		private B theBuilder = this.getThis();

		public Builder() {
		}

		protected abstract B getThis();

		public B setCreateTime(Long createTime) {
			this.createTime = createTime;
			return this.theBuilder;
		}

		public B setAppId(String appId) {
			this.appId = appId;
			return this.theBuilder;
		}

		public B setScope(String scope) {
			this.scope = scope;
			return this.theBuilder;
		}

		public B setId(String id) {
			this.id = id;
			return this.theBuilder;
		}

		public B setCmd(Integer cmd) {
			this.cmd = cmd;
			return this.theBuilder;
		}

		public B addExtra(String key, Object value) {
			if (null == value) {
				return this.theBuilder;
			} else {
				if (null == this.extras) {
					this.extras = new JSONObject();
				}

				this.extras.put(key, value);
				return this.theBuilder;
			}
		}

		public abstract T build();
	}
}
